﻿using System.ServiceModel;
using EconomicInformationServiceWcf.ServiceBehaviours;
using Framework.Exceptions;
using Framework.Security;
using Interfaces.Enums;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF;
using ServiceInfrastructure.Models.Exceptions;
using ServiceInfrastructure.Models.SecurityModels;
using ServiceInfrastructure.ServiceConstants;
using SoapHeaderDirection = System.Web.Services.Protocols.SoapHeaderDirection;

namespace EconomicInformationServiceWcf
{
    [ServiceContract(Name = ServiceConstants.SecurityServicecontract,
        Namespace = ServiceConstants.SecurityServicenamespace)]
    [EISHeaders]
    [EISApplication]
    [ExceptionShielding(PolicyNames.SecurityPolicy)]
    public interface ISecurityService
    {
        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(GeneralFault))]
        [EISHeader(ServiceConstants.Headername, typeof(EISSession), Direction = SoapHeaderDirection.Out)]
        void Login(LoginRequest request);

        [OperationContract]
        [FaultContract(typeof(SecurityFault))]
        [FaultContract(typeof(GeneralFault))]
        [EISHeader(ServiceConstants.Headername, typeof(EISSession), Direction = SoapHeaderDirection.InOut)]
        void Logout();

        [OperationContract]
        [FaultContract(typeof (GeneralFault))]
        [FaultContract(typeof (BusinessFault))]
        void Register(RegisterRequest request);

        [OperationContract]
        [FaultContract(typeof(GeneralFault))]
        [FaultContract(typeof(BusinessFault))]
        [FaultContract(typeof(SecurityFault))]
        [EISHeader(ServiceConstants.Headername,typeof(EISSession),Direction = SoapHeaderDirection.In)]
        [EISAutorize(Permissions = new [] {RoleType.Admin})]
        void AddRole(RoleOperationRequest request);

        [OperationContract]
        [FaultContract(typeof(GeneralFault))]
        [FaultContract(typeof(BusinessFault))]
        [FaultContract(typeof(SecurityFault))]
        [EISHeader(ServiceConstants.Headername, typeof(EISSession), Direction = SoapHeaderDirection.In)]
        [EISAutorize(Permissions = new[] { RoleType.Admin })]
        void RemoveRole(RoleOperationRequest request);

        [OperationContract]
        [FaultContract(typeof (GeneralFault))]
        [FaultContract(typeof (BusinessFault))]
        [FaultContract(typeof(SecurityFault))]
        [EISHeader(ServiceConstants.Headername, typeof (EISSession), Direction = SoapHeaderDirection.In)]
        [EISAutorize(Permissions = new[] {RoleType.Admin})]
        void DeleteUser(DeleteUserRequest request);

        [OperationContract]
        [FaultContract(typeof (GeneralFault))]
        [FaultContract(typeof (BusinessFault))]
        [FaultContract(typeof (SecurityFault))]
        [EISHeader(ServiceConstants.Headername, typeof (EISSession), Direction = SoapHeaderDirection.In)]
        [EISAutorize(Permissions = new[] {RoleType.Admin, RoleType.User })]
        void ChangePassword(ChangePasswordRequest request);

        [OperationContract]
        [FaultContract(typeof(GeneralFault))]
        [FaultContract(typeof(BusinessFault))]
        [FaultContract(typeof(SecurityFault))]
        [EISHeader(ServiceConstants.Headername, typeof(EISSession), Direction = SoapHeaderDirection.In)]
        [EISAutorize(Permissions = new[] { RoleType.Admin })]
        void ResetPassword(ResetPasswordRequest request);

        [OperationContract]
        [FaultContract(typeof(GeneralFault))]
        [FaultContract(typeof(BusinessFault))]
        [FaultContract(typeof(SecurityFault))]
        [EISHeader(ServiceConstants.Headername, typeof(EISSession), Direction = SoapHeaderDirection.In)]
        [EISAutorize(Permissions = new[] { RoleType.Admin })]
        GetUsersResponse GetUsers();

        [OperationContract]
        [FaultContract(typeof(GeneralFault))]
        [FaultContract(typeof(BusinessFault))]
        [FaultContract(typeof(SecurityFault))]
        [EISHeader(ServiceConstants.Headername, typeof(EISSession), Direction = SoapHeaderDirection.In)]
        [EISAutorize(Permissions = new[] { RoleType.Admin })]
        GetRolesResponse GetRoles();
    }
   
}
